#!/bin/bash

echo "===================================="
echo "数据库更新脚本执行工具"
echo "===================================="
echo ""

# 设置数据库连接参数
DB_HOST="106.52.158.123"
DB_PORT="3306"
DB_NAME="kaizeli"
DB_USER="kaizeli_ddl"
DB_PASS="DDL_password123!"

echo "正在连接数据库..."
echo "主机: $DB_HOST"
echo "端口: $DB_PORT"
echo "数据库: $DB_NAME"
echo "用户: $DB_USER"
echo ""

# 检查mysql命令是否存在
if ! command -v mysql &> /dev/null; then
    echo "错误: 未找到mysql命令，请确保MySQL客户端已安装"
    exit 1
fi

echo "执行数据库更新脚本..."
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" < update_database_to_bigint.sql

if [ $? -eq 0 ]; then
    echo ""
    echo "===================================="
    echo "数据库更新成功完成！"
    echo "===================================="
else
    echo ""
    echo "===================================="
    echo "数据库更新失败！错误代码: $?"
    echo "===================================="
fi
